AutomatListView = new function(){
    this.init = _init;
    var _initData;
    
    function _init(data){
        _initData = data;
        _setEvents();
    }
    
    function _setEvents(){
        $('.automate-info-block').mouseover(
            function(){
                $(this).addClass('highlight')
            }
        ).mouseout(
            function(){
                $(this).removeClass('highlight');
            }
        ).click(
            function(){
                var contentPos = $('#content').position();
                var curPos = $(this).position();
                var targetHeight = $(window).height() - contentPos.top;
                var targetWidth = $('#content').width() - 17;
                var prevContent = $(this).html();
                var automateId = $(this).children('input').val();
                $(this).replaceWith("<div id='details'></div>");
                $('#details').html("<div class='loading'>Loading...</div>")
                    .css('position','absolute')
                    .css('left', curPos.left).css('top', curPos.top)
                    .animate({height : targetHeight, 
                                 width : targetWidth,
                                 left : contentPos.left,
                                 top : contentPos.top
                                }, 
                                500, 
                                'linear', 
                                function(){
                                    $('#details').css('position','inherit');
                                    $('#content').html($('#details'));
                                    $('#details').load(_initData.detailsUrl,{'automatId':automateId});
                                });
            }
        );
    }
    
}
